<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="../../../common/common-easyui.jspf" %>
<!DOCTYPE html >
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>规则维护</title>
</head>
<body>
<table id="dg" title="规则维护表" class="easyui-datagrid" style="width:100%;height:100%"
       data-options="
			url:'ruleInfoController?flag=query',
			toolbar:'#toolbar',
			rownumbers:'true', fitColumns:'true', singleSelect:'true'">
    <thead>
    <tr>
        <th data-options="field:'ruleId'" width="50">规则编号</th>
        <th data-options="field:'scNumber'" width="50">单选题个数</th>
        <th data-options="field:'scScore'" width="50">单选题总分</th>
        <th data-options="field:'scIds'" width="50">单选题编号</th>
        <th data-options="field:'mulNumber'" width="50">多选题个数</th>
        <th data-options="field:'mulScore'" width="50">多选题总分</th>
        <th data-options="field:'mulIds'" width="50">多选题编号</th>
        <th data-options="field:'bkNumber'" width="50">填空题个数</th>
        <th data-options="field:'bkScore'" width="50">填空题总分</th>
        <th data-options="field:'bkIds'" width="50">填空题编号</th>
        <th data-options="field:'jdNumber'" width="50">判断题个数</th>
        <th data-options="field:'jdScore'" width="50">判断题总分</th>
        <th data-options="field:'jdIds'" width="50">判断题编号</th>
        <th data-options="field:'subNumber'" width="50">主观题个数</th>
        <th data-options="field:'subScore'" width="50">主观题总分</th>
        <th data-options="field:'subIds'" width="50">主观题编号</th>
        <th data-options="field:'totalScore'" width="50">试卷总分</th>
        <th data-options="field:'testType'" width="50">组卷类型</th>
    </tr>
    </thead>
</table>
<div id="toolbar">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add', plain:'true'" onclick="newRule()">添加规则</a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-edit', plain:'true'" onclick="editRule()">编辑规则</a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-remove', plain:'true'" onclick="destroyRule()">移除规则</a>
</div>
<div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
     data-options="closed:'true', buttons:'#dlg-buttons'">
    <div class="ftitle">规则信息</div>
    <form id="fm" method="post">
        <div class="fitem">
            <label>单选题个数:</label>
            <input name="scNumber">
        </div>
        <div class="fitem">
            <label>单选题总分:</label>
            <input name="scScore">
        </div>
        <div class="fitem">
            <label>单选题编号:</label>
            <input name="scIds">
        </div>
        <div class="fitem">
            <label>多选题个数:</label>
            <input name="mulNumber">
        </div>
        <div class="fitem">
            <label>多选题总分:</label>
            <input name="mulScore">
        </div>
        <div class="fitem">
            <label>多选题编号:</label>
            <input name="mulIds">
        </div>
        <div class="fitem">
            <label>填空题个数:</label>
            <input name="bkNumber">
        </div>
        <div class="fitem">
            <label>填空题总分:</label>
            <input name="bkScore">
        </div>
        <div class="fitem">
            <label>填空题编号:</label>
            <input name="bkIds">
        </div>
        <div class="fitem">
            <label>判断题个数:</label>
            <input name="jdNumber">
        </div>
        <div class="fitem">
            <label>判断题总分:</label>
            <input name="jdScore">
        </div>
        <div class="fitem">
            <label>判断题编号:</label>
            <input name="jdIds">
        </div>
        <div class="fitem">
            <label>主观题个数:</label>
            <input name="subNumber">
        </div>
        <div class="fitem">
            <label>主观题总分:</label>
            <input name="subScore">
        </div>
        <div class="fitem">
            <label>主观题编号:</label>
            <input name="subIds">
        </div>
        <div class="fitem">
            <label>试卷总分:</label>
            <input name="totalScore">
        </div>
        <div class="fitem">
            <label>组卷类型:</label>
            <input name="testType">
        </div>

    </form>
</div>
<div id="dlg-buttons">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="saveRule()">Save</a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'"
       onclick="javascript:$('#dlg').dialog('close')">Cancel</a>
</div>
<script type="text/javascript">
    //添加函数
    function newRule() {
        $('#dlg').dialog('open').dialog('setTitle', '添加组卷规则');
        $('#fm').form('clear');
        url = 'ruleInfoController?flag=add';
    }
    //修改函数
    function editRule() {
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            $('#dlg').dialog('open').dialog('setTitle', '修改组卷规则');
            $('#fm').form('load', row);
            url = 'ruleInfoController?flag=update&ruleId=' + row.ruleId;
        }
    }
    //保存函数
    function saveRule() {
        $('#fm').form('submit', {
            url: url,
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: function (data) {

                if (data == "ok") {
                    $('#dlg').dialog('close');		// 清除数据
                    $('#dg').datagrid('reload');	// 重新加载数据
                } else {
                    $.messager.show({
                        title: 'Error',
                        msg: result.errorMsg
                    });
                }
            }
        });
    }
    //删除函数
    function destroyRule() {
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            $.messager.confirm('Confirm', '确定删除吗?', function (r) {
                if (r) {
                    $.get('ruleInfoController', {flag: "dele", ruleId: row.ruleId}, function (data) {
                        if (data == "ok") {
                            $('#dg').datagrid('reload');	// 重新加载数据
                        } else {
                            $.messager.show({	//错误提示
                                title: 'Error',
                                msg: result.errorMsg
                            });
                        }
                    });
                }
            });
        }
    }
</script>
</body>
</html>